/**
 *
 */
package net.jadoth.util;

/**
 * @author Thomas Muenz
 *
 */
public interface Pair<F,S>
{
	public F first();
	public S second();
	
	
	public class Implementation<F,S> implements Pair<F,S>, KeyValue<F, S>
	{
		private final F first;
		private final S second;
		
		public Implementation(final F first, final S second)
		{
			super();
			this.first = first;
			this.second = second;
		}
			
		
		@Override
		public F first()
		{
			return this.first;
		}
		@Override
		public S second()
		{
			return this.second;
		}
		
		/**
		 * @return a String of pattern <code>(<i>first</i>,<i>second</i>)</code>
		 */
		@Override
		public String toString()
		{
			// self-reference can never occur as this implementation is immutable
			return '('+String.valueOf(this.first)+','+String.valueOf(this.second)+')';
		}


		/**
		 * @return
		 */
		@Override
		public F key()
		{
			return this.first;
		}


		/**
		 * @return
		 */
		@Override
		public S value()
		{
			return this.second;
		}
		
	}
}
